<template xmlns:el-col="http://www.w3.org/1999/html">
  <div>
    <div>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick" >
        <el-tab-pane label="招聘信息管理" name="first" >
          <div>
            <div>
              <el-cow>
                <el-col :span="6">
                  <el-input
                    v-model="searchDepJobneed"
                    placeholder="根据部门ID查找内容"
                    prefix-icon="el-icon-search"
                    @input="searchJobneed"
                  ></el-input>
                </el-col>

                <el-col :span="4">
                  <el-button @click="exportExcelForDepJobneed">导出部门岗位信息表</el-button>
                </el-col>
                <el-col :span="4">
                  <el-button @click="OutLogin" >返回登录界面</el-button>
                </el-col>
              </el-cow>
            </div>
            <div>


              <el-table
                :data="jobneed"
                :row-style="{height: '0'}"
                :cell-style="{padding: '0'}"
                style="width: 100%"
                @row-click="getDetails"
                id="out-tableforjob"
              >
                <!--        <el-table-column label width="35">-->
                <!--          <template slot-scope="scope">-->
                <!--            <el-radio :label="scope.row.name" v-model="radioId">&nbsp;</el-radio>-->
                <!--          </template>-->
                <!--        </el-table-column>-->
                <el-table-column align="center" prop="jobrage" label="招聘序列" width="80"></el-table-column>
                <el-table-column align="center" prop="departmentId" label="部门Id" width="100"fixed></el-table-column>
                <el-table-column align="center" prop="departmentName" label="部门名称" width="100" fixed></el-table-column>
                <el-table-column align="center" prop="workName" label="职位" width="100"></el-table-column>
                <el-table-column align="center" prop="baseSalary" label="基础薪资" width="100"></el-table-column>
                <el-table-column align="center" prop="userId" label="部长Id" width="75"></el-table-column>
                <el-table-column align="center" prop="username" label="部长姓名" width="100"></el-table-column>
                <el-table-column align="center" prop="needNum" label="岗位需求人数" width="120"></el-table-column>
                <el-table-column align="center" prop="description" label="职位描述" width="400"></el-table-column>

                <el-table-column fixed="right" width="400" label="操作" id="work">
                  <template slot-scope="scope">
                    <!--                  <el-button v-show="scope.row.role == 'user'&&scope.row.iswork==`0`" @click="addNewDeper(scope.row)"style="padding: 3px" size="mini" type="success">添加部门成员</el-button>-->
                    <!--                  <el-button v-show="scope.row.role =='user'&&scope.row.iswork==`1`" @click="openshowDeper(scope.row)"style="padding: 3px" size="mini" type="primary">查看所属部长</el-button>-->
                    <!--                  <el-button v-show="scope.row.role =='department'" @click="changeNewDeper(scope.row)"style="padding: 3px" size="mini" type="warning">更换部门部长</el-button>-->
                    <!--                  -->
                    <el-button @click="showWorkMsg(scope.row)" style="padding: 3px" size="mini" type="success">查看岗位详细信息</el-button>
                    <el-button @click="JoinThisClub(scope.row)" style="padding: 3px" size="mini" type="primary">在线投稿简历</el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>





        </el-tab-pane>


      </el-tabs>



    </div>
    <el-dialog
      title="初始新成员信息"
      :visible.sync="openEnterDialog"
      width="80%"
      :before-close="handleClose">
      <el-form ref="form" label-width="100px" v-model="wanteds" >
        <el-row>

          <el-col :span="6">
            <el-form-item label="员工姓名" prop="name">
              <el-input v-model="wanteds.username" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="身份证号码" prop="name">
              <el-input v-model="wanteds.idcard"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="性别:" prop="name">
              <el-input v-model="wanteds.gender" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="政治面貌" prop="name">
              <el-input v-model="wanteds.politicaltype" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="民族" prop="name">
              <el-input v-model="wanteds.nationId" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="地址" prop="name">
              <el-input v-model="wanteds.address" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="邮箱" prop="name">
              <el-input v-model="wanteds.email" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="电话" prop="name">
              <el-input v-model="wanteds.phone" ></el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="最高学历" prop="name">
              <el-input v-model="wanteds.education" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="毕业专业" prop="name">
              <el-input v-model="wanteds.educationsubject" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="毕业院校" prop="name">
              <el-input v-model="wanteds.school" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="部门Id" prop="name">
              <el-input v-model="wanteds.departmentId" disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="部门名" prop="name">
              <el-input v-model="wanteds.departmentName" disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="职位" prop="name">
              <el-input v-model="wanteds.workName" disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪资" prop="name">
              <el-input v-model="wanteds.baseSalary" disabled="true"></el-input>
            </el-form-item>
          </el-col>


        </el-row>
        <el-row>
          <el-col :span="18">
            <el-form-item label="岗位要求" prop="name">
              <el-input
                type="textarea"
                :autosize="{minRows:3,maxRows:6}"
                v-model="jobneeds.description"
                disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="18">
            <el-form-item label="个人经历" prop="name">
              <el-input
                type="textarea"
                :autosize="{minRows:3,maxRows:6}"
                v-model="wanteds.workExperience"

              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="6">-->
<!--            <el-form-item label="新建员工Id" prop="name">-->
<!--              <el-input v-model="NewuserId" @change="userIdIsIllegal(NewuserId)"></el-input>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="6">-->
<!--            <el-form-item label="" prop="name">-->
<!--              <el-button  @click="userIdIsIllegal(NewuserId)"  >检测是否合法</el-button>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="6">-->
<!--            <el-form-item label="新建员工工号" prop="name">-->
<!--              <el-input v-model="NewworkId" @change="workIdIsIllegal(NewworkId)" ></el-input>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="6">-->
<!--            <el-form-item label="" prop="name">-->
<!--              <el-button @click="workIdIsIllegal(NewworkId)" >检测是否合法</el-button>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="6">
            <el-form-item label="" prop="name">
              <el-button @click="InsertWanted" >线上投稿简历！</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>


    </el-dialog>

  </div>


</template>

<script>
  import FileSaver from 'file-saver'
  import XLSX from 'xlsx'
  export default {
    name: "forjob",
    data()
    {
      return{
        NewuserId:"",
        checkuserId:"",
        NewworkId:"",
        checkworkId:"",
        searchDepJobneed:"",
        activeName:"first",
        openInsertDialog:false,
        DepId:"请选择部门",
        DepIds:[],
        jobneed:[],
        jobneeds:{
          jobrage:"",
          departmentId:"",
          departmentName:"",
          userId:"",
          username:"",
          workName:"",
          baseSalary:"",
          description:"",
          needNum:"",
        },
        openEnterDialog:false,
        searchWanted:"",
        searchWorkName:"",
        wanted:[],
        changeMsgDialog:false,
        wanteds:{
          wantedrage:"",
          username:"",
          idcard:"",
          gender:"",
          politicaltype:"",
          nationId:"",
          address:"",
          email:"",
          phone:"",
          education:"",
          educationsubject:"",
          school:"",
          departmentId: "",
          departmentName: "",
          workName:"",
          baseSalary: "",
          workExperience:"",
          isaccept:""
        },
      }
    },
    mounted() {
      this.$store.state.departmentId = window.sessionStorage.getItem("departmentId")
      this.$store.state.userId = window.sessionStorage.getItem("userId")

      this.selectAllJobneed()

    },
    methods:
      {
        handleClick(tab, event) {
          if (tab.index == 0) {
            // alert("啦啦啦")
            this.selectAllJobneed()
          } else if (tab.index == 1) {

            this.selectAllWanted()


          }
        },
        InsertWanted()
        {
          this.$axios.post("/wanted/InsertNewWanteds",{
            username:this.wanteds.username,
            idcard:this.wanteds.idcard,
            gender:this.wanteds.gender,
            politicaltype:this.wanteds.politicaltype,
            nationId:this.wanteds.nationId,
            address:this.wanteds.address,
            email:this.wanteds.email,
            phone:this.wanteds.phone,
            education:this.wanteds.education,
            educationsubject:this.wanteds.educationsubject,
            school:this.wanteds.school,
            departmentId: this.wanteds.departmentId,
            departmentName: this.wanteds.departmentName,
            workName:this.wanteds.workName,
            baseSalary: this.wanteds.baseSalary,
            workExperience:this.wanteds.workExperience,
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch((res)=>{
            this.$message.error("投稿失败，请重试！")
          }).finally(()=>{
            this.openEnterDialog = false
          })
        },
        JoinThisClub(data)
        {
          this.wanteds = []
          this.jobneeds =data
          this.wanteds.baseSalary = this.jobneeds.baseSalary
          this.wanteds.workName = this.jobneeds.workName
          this.wanteds.departmentId = this.jobneeds.departmentId
          this.wanteds.departmentName = this.jobneeds.departmentName
          this.openEnterDialog = true
        },
        userIdIsIllegal(data)
        {
          this.$axios.post("/wanted/userIdIsIllegal",{
            userId:data
          }).then((res)=>{
            this.$message.success(res.data.msg)
            this.checkuserId = 1
          }).catch(()=>{
            this.checkuserId = 0
            this.$message.error("不合法！")
          }).finally(()=>{

          })
        },
        InsertNewEmp()
        {
          this.$axios.post("/wanted/InsertNewEmp",{
            wantedrage:this.wanteds.wantedrage,
            username:this.wanteds.username,
            idcard:this.wanteds.idcard,
            gender:this.wanteds.gender,
            politicaltype:this.wanteds.politicaltype,
            nationId:this.wanteds.nationId,
            address:this.wanteds.address,
            email:this.wanteds.email,
            phone:this.wanteds.phone,
            education:this.wanteds.education,
            educationsubject:this.wanteds.educationsubject,
            school:this.wanteds.school,
            departmentId: this.wanteds.departmentId,
            departmentName: this.wanteds.departmentName,
            workName:this.wanteds.workName,
            baseSalary: this.wanteds.baseSalary,
            workExperience:this.wanteds.workExperience,
            userId:this.NewuserId,
            workId:this.NewworkId,
            isaccept: 2
          }).then((res)=>{

            this.$message.success(res.data.msg)
          }).catch(()=>{

            this.$message.error("新增失败！")
          }).finally(()=>{

          })
        },
        workIdIsIllegal(data)
        {
          this.$axios.post("/wanted/workIdIsIllegal",{
            workId:data,
            departmentId:this.wanteds.departmentId
          }).then((res)=>{
            this.checkworkId = 1
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.checkworkId = 0
            this.$message.error("不合法！")
          }).finally(()=>{

          })
        },
        EnterEnterPrice(data)
        {
          this.wanteds = data
          this.openEnterDialog = true
        },
        getdepartmentDetail(data)
        {
          this.$axios.post("/Jobneed/selectDepByDepartmentId",{
            departmentId:data
          }).then((res)=>{
            this.jobneeds = res.data

          })
        },
        reloadAllDep()
        {
          this.$axios.post("/Jobneed/selectDepartmentId",{

          }).then((res)=>{
            this.DepIds = res.data
            // alert(JSON.stringify(this.DepIds))
          })
        },
        searchJobneed()
        {
          if(this.searchDepJobneed == ''|| this.searchDepJobneed =='undefined'||this.searchDepJobneed == null)
          {
            this.selectAllJobneed()
          }else {
            this.selectAllJobneedBydepartmentId();
          }
        },
        searchWantneed()
        {
          if(this.searchWanted == ''|| this.searchWanted =='undefined'||this.searchWanted == null)
          {
            this.selectAllWanted()
          }else  if(!(this.searchWanted == ''|| this.searchWanted =='undefined'||this.searchWorkName == null)
            &&(this.searchWorkName == ''|| this.searchWorkName =='undefined'||this.searchWorkName == null)
          ){
            this.selectWantedByAdminSearch()
          }
          else {
            this.selectWantedByDepIdAndWorkName(this.searchWanted,this.searchWorkName)
          }
        },
        delwantedByWantedrage(data)
        {
          this.$axios.post("/wanted/deleteWantedByWantedRage",{
            wantedrage:data.wantedrage
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("删除失败")
          }).finally(()=>{
            this.selectWantedBydepartmentId()
          })
        },
        updateWantedIsacceptBywantedrage(data,isaccept)
        {
          this.$axios.post(("/wanted/updateWantedIsacceptBywantedrage"),{
            wantedrage:data.wantedrage,
            isaccept:isaccept,
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("修改失败")
          }).finally(()=>{
            this.selectWantedBydepartmentId()
          })
        },



        updateAllWantedIsacceptBywantedrage(data,isaccept)
        {
          this.$axios.post(("/wanted/updateWantedIsacceptBywantedrage"),{
            wantedrage:data.wantedrage,
            isaccept:isaccept,
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("修改失败")
          }).finally(()=>{
            this.selectAllJobneedBydepartmentId()
          })
        },
        selectAllWanted()
        {
          this.$axios.post("/wanted/selectAllWanted",{

          }).then((res)=>{
            this.wanted = res.data
            // alert(JSON.stringify(res.data))
            this.$message.success("加载成功！")
          })
        },
        selectWantedBydepartmentId()
        {
          this.$axios.post("/wanted/selectWantedBydepartmentId",{
            departmentId:this.$store.state.departmentId
          }).then((res)=>{
            this.wanted = res.data
            // alert(JSON.stringify(res.data))
            this.$message.success("加载成功！")
          })
        },
        selectWantedByAdminSearch()
        {
          this.$axios.post("/wanted/selectWantedBydepartmentId",{
            departmentId:this.searchWanted
          }).then((res)=>{
            this.wanted = res.data
            // alert(JSON.stringify(res.data))
            this.$message.success("加载成功！")
          })
        },
        selectWantedByDepIdAndWorkName(departmentId,workName)
        {
          this.$axios.post("/wanted/selectWantedByDepartmentIdAndworkName",{
            departmentId:departmentId,
            workName:workName
          }).then((res)=>{
            this.wanted = res.data
          })
        },
        selectDepWantedByIsaccept(data)
        {
          this.$axios.post("/wanted/selectWantedByIsaccept",{
            departmentId:this.$store.state.departmentId,
            isaccept:data,
          }).then((res)=>{

            this.wanted = []
            this.wanted = res.data
            this.$message.success("加载成功")
          })
        },
        selectWantedByIsaccept(data)
        {
          this.$axios.post("/wanted/selectWantedByIsaccept",{
            isaccept:data
          }).then((res)=>{

            this.wanted = []
            this.wanted = res.data
            this.$message.success("加载成功")
          })
        },
        changeIsaccept(row)
        {
          if(row.isaccept=='1')
          {
            return "面试通过"
          }
          else if(row.isaccept=='0'){
            return "未审核"
          }
          else if(row.isaccept=='2'){
            return "面试失败"
          }
          else if(row.isaccept=='3')
          {
            return "正式员工"
          }else if(row.isaccept=='4')
          {
            return "等待面试"
          }
        },
        InsertNewWork() {
          this.$axios.post("/Jobneed/InsertJobneed",{
            departmentId:this.DepId,
            departmentName:this.jobneeds.departmentName,
            userId:this.jobneeds.userId,
            username:this.jobneeds.username,
            workName:this.jobneeds.workName,
            baseSalary:this.jobneeds.baseSalary,
            description:this.jobneeds.description,
            needNum:this.jobneeds.needNum
          }).then((res)=>{

            this.$message.success(res.data.msg)
            this.openInsertDialog = false
          }).catch(()=>{
            this.$message.error("新建失败！职位名不可重复!")
          }).finally(()=>{
            this.DepId = "选择部门"
            this.selectAllJobneed()

          })

        },
        ChangeThisWork() {

          this.$axios.post("/Jobneed/UpdateJobneedByJobrage",{

            jobrage:this.jobneeds.jobrage,
            departmentId:this.jobneeds.departmentId,
            departmentName:this.jobneeds.departmentName,
            userId:this.jobneeds.userId,
            username:this.jobneeds.username,
            workName:this.jobneeds.workName,
            baseSalary:this.jobneeds.baseSalary,
            description:this.jobneeds.description,
            needNum:this.jobneeds.needNum,
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("修改失败！")
          }).finally(()=>{
            this.selectAllJobneed()
            this.changeMsgDialog = false
          })



        },
        InsertNewWorkDialog() {
          // alert(JSON.stringify(this.$store.state.userId))
          this.$axios.post("/Jobneed/SelectDepUserNameBeforeInsert",{
            userId:this.$store.state.userId
          }).then((res)=>{


            // this.jobneeds.username = res.data.username
            // this.jobneeds.departmentName = res.data.departmentName
            // this.jobneeds.userId = this.$store.state.userId
            // this.jobneeds.departmentId = this.$store.state.departmentId
            this.jobneeds.username = ""
            this.jobneeds.departmentName = ""
            this.jobneeds.userId = ""
            this.jobneeds.departmentId = ""
            this.jobneeds.workName="",
              this.jobneeds.baseSalary="",
              this.jobneeds.description="",
              this.jobneeds.needNum=""
            this.jobneeds.jobrage = ""
          })
          this.reloadAllDep()
          this.openInsertDialog = true;
        },
        handleClose() {
          this.openEnterDialog = false
          this.openInsertDialog = false
        },
        showWorkMsg(data) {
          alert("岗位信息：\n部门Id：" +
            JSON.stringify(data.departmentId).replace(/\"/g, "") + ";\n部门名称：" +
            JSON.stringify(data.departmentName).replace(/\"/g, "") + "；\n部长ID：" +
            JSON.stringify(data.userId).replace(/\"/g, "") + "；\n部长名称：" +
            JSON.stringify(data.username).replace(/\"/g, "") + ";\n岗位名：" +
            JSON.stringify(data.workName).replace(/\"/g, "") + ";\n需求人数：" +
            JSON.stringify(data.needNum).replace(/\"/g, "") + ";\n岗位要求：" +
            JSON.stringify(data.description).replace(/\"/g, "")
          )
        },
        showWorkerMsg(data) {
          alert("求职者信息：\n部门Id：" +
            JSON.stringify(data.departmentId).replace(/\"/g, "") + ";\n部门名称：" +
            JSON.stringify(data.departmentName).replace(/\"/g, "") + "；\n求职者姓名：" +
            JSON.stringify(data.username).replace(/\"/g, "") + ";\n岗位名：" +
            JSON.stringify(data.workName).replace(/\"/g, "") + ";\n薪资：" +
            JSON.stringify(data.baseSalary).replace(/\"/g, "") + "；\n应聘序列：" +
            JSON.stringify(data.wantedrage).replace(/\"/g, "") + ";\n员工身份证号码：" +
            JSON.stringify(data.idcard).replace(/\"/g, "") + ";\n员工性别：" +
            JSON.stringify(data.gender).replace(/\"/g, "") + ";\n员工政治面貌：" +
            JSON.stringify(data.politicaltype).replace(/\"/g, "") + ";\n员工民族：" +
            JSON.stringify(data.nationId).replace(/\"/g, "") + ";\n员工地址：" +
            JSON.stringify(data.address).replace(/\"/g, "") + ";\n员工邮箱：" +
            JSON.stringify(data.email).replace(/\"/g, "") + ";\n员工电话号码：" +
            JSON.stringify(data.phone).replace(/\"/g, "") + ";\n员工最高学历：" +
            JSON.stringify(data.education).replace(/\"/g, "") + ";\n员工专业：" +
            JSON.stringify(data.educationsubject).replace(/\"/g, "") + ";\n员工最高学历毕业院校：" +
            JSON.stringify(data.school).replace(/\"/g, "") + ";\n求职工作经历、项目介绍：" +
            JSON.stringify(data.workExperience).replace(/\"/g, "")
          )
        },
        accDep(data) {

        },
        refDep(data) {

        },
        changeMsg(data) {
          this.jobneeds = data
          this.changeMsgDialog = true
        },
        delWork(data) {
          this.$confirm('此操作将删除【' + JSON.stringify(data.workName).replace(/\"/g, "") + '】岗位的信息,是否继续？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {

            this.$axios.post("/Jobneed/deleteJobneedByJobrage",{
              jobrage:data.jobrage
            }).then((res)=>{
              this.$message.success(res.data.msg)
            }).catch(()=>{
              this.$message.error("删除失败捏")
            }).finally(()=>{
              this.selectAllJobneed()
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });
          });
        },
        selectAllJobneed() {
          this.$axios.post("/Jobneed/SelectAllJobneed", {}).then((res) => {
            this.jobneed = res.data
          })
        },
        selectAllJobneedBydepartmentId()
        {
          this.$axios.post("/Jobneed/SelectAllJobneedBydepartmentId", {
            departmentId:this.searchDepJobneed,
          }).then((res) => {

            this.jobneed = res.data
          })
        },

        exportExcel() {
          let xlsxParam = { raw: true }; //转换成excel时，使用原始的格式
          / generate workbook object from table /;
          /* 从表生成工作簿对象 */
          let table =  document.querySelector("#out-tableWork").cloneNode(true)
          // 因为element-ui的表格的fixed属性导致多出一个table，会下载重复内容，这里删除掉
          table.removeChild(table.querySelector(".el-table__fixed-right"));
          table.removeChild(table.querySelector(".el-table__fixed"));
          let wb = XLSX.utils.table_to_book(
            table ,  //elementui 表格的id
            xlsxParam
          );

          /* 获取二进制字符串作为输出 */
          var wbout = XLSX.write(wb, {
            bookType: "xlsx",
            bookSST: true,
            type: "array"
          });
          try {
            FileSaver.saveAs(
              //Blob 对象表示一个不可变、原始数据的类文件对象。
              //Blob 表示的不一定是JavaScript原生格式的数据。
              //File 接口基于Blob，继承了 blob 的功能并将其扩展使其支持用户系统上的文件。
              //返回一个新创建的 Blob 对象，其内容由参数中给定的数组串联组成。
              new Blob([wbout], { type: "application/octet-stream" }),
              //设置导出文件名称
              "部门岗位表.xlsx"
            );
          } catch (e) {
            if (typeof console !== "undefined") console.log(e, wbout);
          }
          return wbout;
        },
        OutLogin()
        {
          window.sessionStorage.removeItem("userId")
          window.sessionStorage.removeItem("role")
          window.sessionStorage.removeItem("departmentId")
          this.$router.push({path:'/'});
        },
        exportExcelForDepJobneed() {
          let xlsxParam = { raw: true }; //转换成excel时，使用原始的格式
          / generate workbook object from table /;
          /* 从表生成工作簿对象 */
          let table =  document.querySelector("#out-tableforjob").cloneNode(true)
          // 因为element-ui的表格的fixed属性导致多出一个table，会下载重复内容，这里删除掉
          table.removeChild(table.querySelector(".el-table__fixed-right"));
          table.removeChild(table.querySelector(".el-table__fixed"));
          let wb = XLSX.utils.table_to_book(
            table ,  //elementui 表格的id
            xlsxParam
          );

          /* 获取二进制字符串作为输出 */
          var wbout = XLSX.write(wb, {
            bookType: "xlsx",
            bookSST: true,
            type: "array"
          });
          try {
            FileSaver.saveAs(
              //Blob 对象表示一个不可变、原始数据的类文件对象。
              //Blob 表示的不一定是JavaScript原生格式的数据。
              //File 接口基于Blob，继承了 blob 的功能并将其扩展使其支持用户系统上的文件。
              //返回一个新创建的 Blob 对象，其内容由参数中给定的数组串联组成。
              new Blob([wbout], { type: "application/octet-stream" }),
              //设置导出文件名称
              "部门岗位表.xlsx"
            );
          } catch (e) {
            if (typeof console !== "undefined") console.log(e, wbout);
          }
          return wbout;
        },
      }
  }
</script>

<style scoped>

</style>
